package com.violet.constlib

import java.lang.Exception


data class Resource<out T>(val status: Status, val data: T?, val message: Exception?, val hasMore: Boolean) {
    companion object {
        fun <T> success(data: T, hasMore: Boolean = true): Resource<T> =
            Resource(status = Status.SUCCESS, data = data, message = null, hasMore)

        fun <T> error(data: T? = null, message: Exception): Resource<T> =
            Resource(status = Status.ERROR, data = data, message = message, true)

        fun <T> loading(data: T? = null): Resource<T> =
            Resource(status = Status.LOADING, data = data, message = null, true)
    }
}